home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 8381 / 8381.xpi / chrome / content / webclipper / unix / webclipperOverlay.xul
Extensible Markup Language  |  2010-02-02  |  5KB  |  139 lines

  1. <?xml version="1.0"?>
  2. <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
  3. <?xml-stylesheet href="chrome://webclipper3/skin/webclipperOverlay.css" type="text/css"?>
  4.  
  5. <overlay id="webclipper3Overlay" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
  6.  
  7.   <!-- common function to put the button in the toolbar the first go-round -->
  8.   <script type="application/x-javascript" src="chrome://webclipper3-common/content/toolbar-button-init.js"/>
  9.  
  10. <script type="application/x-javascript">
  11. <![CDATA[
  12. var window_clipped_to_en;
  13. ]]>
  14. </script>
  15. <script type="application/x-javascript" src="http://www.evernote.com/public/bookmarkClipper.js"/>
  16. <script type="application/x-javascript">
  17. <![CDATA[
  18. function evernote_addSelectionToEn3(popupSrc) {
  19.     var br = document.getElementById("content");
  20.     var wnd = null;
  21.     if (br == null || !br.selectedTab || popupSrc)
  22.         wnd = document.commandDispatcher.focusedWindow;
  23.     else
  24.         wnd = br.getBrowserForTab(br.selectedTab).docShell
  25.                            .QueryInterface(Components.interfaces.nsIInterfaceRequestor)
  26.                            .getInterface(Components.interfaces.nsIDOMWindow);
  27.     window_clipped_to_en = wnd;
  28.     EN_CLIP_HOST='http://www.evernote.com';
  29.     EN_clip(EN_CLIP_HOST);
  30.     return true; // handled
  31. }
  32.  
  33.  
  34. function evernote_addToEn3(popupSrc) {
  35.     // see also WhichPaneHasFocus() globally defined function
  36.  
  37.     //use globally defined functions
  38.     try {
  39.         var threadTree = GetThreadTree();
  40.     } catch(e) {
  41.         // GetThreadTree not exists in 'message opened' window
  42.         return evernote_addSelectionToEn3(null);
  43.     }
  44.     if (top.document.commandDispatcher.focusedWindow == GetMessagePaneFrame())
  45.         return evernote_addSelectionToEn3(popupSrc);
  46.  
  47.     var messagePane = GetMessagePane();
  48.     var currentNode = top.document.commandDispatcher.focusedElement;    
  49.     while (currentNode) {
  50.         if (currentNode === messagePane)
  51.             return evernote_addSelectionToEn3(popupSrc);
  52.         else if (currentNode === threadTree)
  53.             return evernote_addSelectedMessagesToEn3();
  54.         currentNode = currentNode.parentNode;
  55.     }
  56.     return evernote_addSelectionToEn3(null); //???
  57. }
  58.  
  59. // uninit under FF/TB 1.5
  60.  
  61. var evernote_uninstallObserver3 = {
  62.     bUninstall:false,
  63.     observe:function(subject, topic, data) {
  64.         if (topic == "em-action-requested") {
  65.             var item = subject.QueryInterface(Components.interfaces.nsIUpdateItem);
  66.             // id from install.rdf <em:id>
  67.             if(item.id == "{E0B8C461-F8FB-49b4-8373-FE32E9252800}") {
  68.                 if (data == "item-uninstalled"){
  69.                     this.bUninstall = true;
  70.                 } else if (data == "item-cancel-action") {
  71.                     this.bUninstall = false;
  72.                 }
  73.             }
  74.         } else if (topic == "quit-application-granted") {
  75.             if (this.bUninstall) {
  76.                 var prefs = Components.classes["@mozilla.org/preferences;1"].getService(Components.interfaces.nsIPrefService);
  77.                 var db = prefs.getBranch(null);
  78.                 db.clearUserPref(evernote_preference3);
  79.             }
  80.             this.unregister();
  81.         }
  82.     },
  83.     register:function() {
  84.         var observerService = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
  85.         observerService.addObserver(this, "em-action-requested", false);
  86.         observerService.addObserver(this, "quit-application-granted", false);
  87.     },
  88.     unregister:function() {
  89.         var observerService = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
  90.         observerService.removeObserver(this,"em-action-requested");
  91.         observerService.removeObserver(this,"quit-application-granted");
  92.     }
  93. }
  94.  
  95. function evernote_setObserver3() {
  96.     evernote_uninstallObserver3.register();
  97. }
  98. window.addEventListener("load", evernote_setObserver3, false);
  99.  
  100. ]]>
  101. </script>
  102.  
  103.  
  104. <!-- This is for the right click menu -->
  105.  
  106. <!-- in Firefox -->
  107.  
  108. <popup id="contentAreaContextMenu">
  109.     <menuseparator id="webclipper-menu-sep" />
  110.     <menuitem id="webclipper3-menu"
  111.     label="Add to Evernote" 
  112.     oncommand="return evernote_addSelectionToEn3(document.popupNode);" />
  113. </popup>
  114.  
  115. <!-- This is for the Tools menu -->
  116.  
  117. <!-- in Firefox -->
  118.  
  119. <menupopup id="menu_ToolsPopup">
  120.     <menuseparator id="webclipper-menu-sep" />
  121.     <menuitem id="webclipper3-menu"
  122.     label="Add to Evernote" 
  123.     oncommand="return evernote_addSelectionToEn3(null);" />    
  124. </menupopup>
  125.  
  126. <!-- This is for the toolbar -->
  127.  
  128. <!-- in Firefox -->
  129.  
  130. <toolbarpalette id="BrowserToolbarPalette">
  131.     <toolbarbutton id="webclipper3-button" label="Add to Evernote"
  132.     class="toolbarbutton-1 chromeclass-toolbar-additional"
  133.     tooltiptext="Add selected text or entire page to Evernote as new note"
  134.     oncommand="return evernote_addSelectionToEn3(null);" />
  135. </toolbarpalette>
  136.  
  137. </overlay>
  138.  
  139.